package com.opener.web.controller;


import com.opener.web.acl.model.User;
import com.opener.web.auth.constant.AuthConstants;
import com.opener.web.auth.model.UserAuthToken;
import org.springframework.web.bind.annotation.ModelAttribute;

import javax.servlet.http.HttpServletRequest;

public class AppAuthBaseController {
	private User loginUser;
	private UserAuthToken authToken;

	public User getLoginUser() {
		loginUser = new User();
		loginUser.setUid(1L);
		return loginUser;
	}


	public void setLoginUser(User loginUser) {
		this.loginUser = loginUser;
	}

	public UserAuthToken getAuthToken() {
		return authToken;
	}

	public void setAuthToken(UserAuthToken authToken) {
		this.authToken = authToken;
	}

	@ModelAttribute
	public void init(HttpServletRequest request) {
		this.loginUser = (User) request.getAttribute(AuthConstants.SessionKey.USER);
		this.authToken = (UserAuthToken) request.getAttribute(AuthConstants.SessionKey.AUTH_TOKEN);
	}
}
